﻿<Page x:Class="Bookworm.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
		xmlns:thriple="http://thriple.codeplex.com/"
    xmlns:m="clr-namespace:Bookworm.Controls;assembly=Bookworm.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:Utilities="clr-namespace:Bookworm.Controls.Utilities;assembly=Bookworm.Controls"
    xmlns:CustomControls="clr-namespace:Bookworm.Controls.CustomControls;assembly=Bookworm.Controls"

        Background="{DynamicResource BWDefault.WindowBrush}"
    Title="BookWorm" 
    x:Name="BWMain">
    <Page.Resources>
        <XmlDataProvider x:Key="booksDS" d:IsDataSource="True" Source="books.xml"/>
        <Utilities:ObjectToImageSourceConverter x:Key="ObjectToImageSourceConverter"/>	
        <DataTemplate x:Key="lstItem">
            <CustomControls:EBookNoteCard x:Name="ebkNoteCard" 
                                      Width="400"
                                      Height="200"
                                      Title="{Binding Mode=Default, XPath=title}"
                                      Author="{Binding Mode=Default, XPath=Author}"
                                      Image="{Binding Mode=Default,Converter={StaticResource ObjectToImageSourceConverter},XPath=image}"/>
        </DataTemplate>
    </Page.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>               
        <ListBox ItemsSource="{Binding Mode=Default, Source={StaticResource booksDS}, XPath=/books/book}"
                 ItemTemplate="{StaticResource lstItem}"
                 Background="{x:Null}"
                 ItemContainerStyle="{DynamicResource bookListStyle}"
                 Grid.Row="1"
                 BorderBrush="{x:Null}"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                 ScrollViewer.VerticalScrollBarVisibility="Auto">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
        </ListBox>        
    </Grid>

</Page>
